import { checkMobile } from 'ph-util'
const ename = checkMobile()?"touchstart":"click"
export default {
    beforeUpdate(el:HTMLElement,binding:any){
        const {value,instance} = binding
        const listener = (e:Event)=>{
            const t = e.target as HTMLElement
            if(el.contains(t))return
            instance.visible = false
        }
        if(value)
            document.addEventListener(ename,listener)
        else
            document.removeEventListener(ename,listener)
    },
}